/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package courseScheduler;

/**
 *
 * @author david
 */
public class BlockNSection {
    private int id;
    private int blockID;
    private int sectionID;

    private java.sql.PreparedStatement getBNSStatement;
    private java.sql.PreparedStatement setBNSStatement;
    private java.sql.PreparedStatement insertBNSStatement;

    private java.sql.Connection conn;

    BlockNSection(int newBlockID, int newSectionID){
        blockID = newBlockID;
        sectionID = newSectionID;
    }


    private void PrepareGetStmnt() throws java.sql.SQLException{
        getBNSStatement = conn.prepareStatement("SELECT block_id,section_id FROM block_section WHERE id =?;");
    }
    
    private void PrepareSetStmnt() throws java.sql.SQLException{
        setBNSStatement = conn.prepareStatement("UPDATE block_section section_id = " + blockID + ",section_id = " + sectionID +" WHERE id = ?;");
    }
    
    private void PrepareInsertStmnt() throws java.sql.SQLException{
        insertBNSStatement = conn.prepareStatement("INSERT INTO block_section (block_id,sectio_id) VALUES (" + blockID + "," + sectionID + ");");
    }

    public final void setBlockID(int newBlockID){
        blockID = newBlockID;
    }

    public int getBlockID(){
        return blockID;
    }

    public final void setSectionID(int newSectionID){
        sectionID = newSectionID;
    }

    public int getSectionID(){
        return sectionID;
    }

    public final void setID(int newID){
        id = newID;
    }

    public int getID (){
        return id;
    }

    public final void setConnection(java.sql.Connection newConn) throws java.sql.SQLException{
        conn = newConn;
        PrepareGetStmnt();
        PrepareSetStmnt();
        PrepareInsertStmnt();
    }
}
